package com.komon.object.request.bodyIO;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * The inputStream used for read date of http body according the "xxx-encoding" header 
 * @author timon.zhang
 */
public abstract class HttpRequestBodyEncodingInputStream extends FilterInputStream {
	protected  AtomicInteger offset = new AtomicInteger(0);
	
	protected HttpRequestBodyEncodingInputStream(InputStream encodingBodyInputStream){
		super(encodingBodyInputStream);
	}
	
	/* (non-Javadoc)
	 * @see java.io.FilterInputStream#read()
	 */
	/**
	 * force sub class rewrite this method.
	 * This method should return a char that already decoded 
	 */
	@Override
	public abstract int read() throws IOException;
	
	/**
	 * If we are not going to parse the body or haven't parse all of the body
	 *  then just skip to next request 
	 * @throws IOException
	 */
	public abstract void skipCurrentRequest() throws IOException;
	
}
